|
|
|
|
|
|
|
Figure 17.9
Set the startup form and other
properties of the project in this dialog box. |
|
|
|
|
|
|
|
|
Creating Multiple Instances of a Form |
|
|
|
|
|
|
|
|
You can use the MDI form just to make your application neater and its forms easier to manage. However, if that's all you use MDI forms for, you're missing out on the real power of MDI applications. The most powerful feature of an MDI application is its capability to create and handle multiple instances of a form at the same time. For example, if you are working in Microsoft Word, each document you open or each new document that you create is a new instance of the same basic form. In fact, many MDI applications are made up of only two forms: the MDI parent form and the template form for all the child forms in the application. |
|
|
|
|
|
|
|
|
|
You can have more than one type of template child form in your application. For example, Visual Basic itself has two basic types of MDI child forms: the Form design child form and the Code child form. You can create as many of each of these types of forms as you need, within the constraints of your system.  |
|
|
|
|
|
|
|
|
|
|
Creating an MDI application of this type requires a little more work than was required in the sample application. You first have to define the basic MDI child form at designtime and then use object variables to create instances of the form at runtime. |
|
|
|
|
|
|
|
|
To start the process of creating an MDI application with multiple instances of a form, you need to start a new project and then add an MDI form to the project as described in the section "Creating a Simple MDI Program." Next, be sure to set up the MDI form as the startup object using the Project Properties dialog box. |
|
|
|
|
|
|
|
|
Setting Up the Basic Form |
|
|
|
|
|
|
|
|
As was the case in the earlier section "Creating a Simple MDI Program," creating the form template is the same as creating a standard form. You add to the form all the controls that you need for the user interface. Also, you need to write any code necessary for the controls to perform their intended functions. You also need to set the MDIChild property of the form to True. |
|
|
|
|
|